package com.gwt.client.event;

import com.google.gwt.event.dom.client.KeyDownEvent;
import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;

public class SlideTransitionEvent extends GwtEvent<SlideTransitionEvent.Handler>{

	public static final Type<Handler> TYPE = new Type<Handler>();

	public interface Handler extends EventHandler {
		void gotoSlide(int nextSlide);
	}
	private KeyDownEvent event;
	
	public SlideTransitionEvent(KeyDownEvent event){
		this.event = event;
	}
	
	@Override
	public Type<Handler> getAssociatedType() {
		return TYPE;
	}

	@Override
	protected void dispatch(Handler handler) {
		if(event.isLeftArrow()){
			handler.gotoSlide(-1);
		} else if(event.isRightArrow()){
			handler.gotoSlide(1);
		} else {
			handler.gotoSlide(0);
		}
	}

	
}
